﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_OtsiAadressiKy_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENOtsiAadressiKyQuery))]
    public class ENOtsiAadressiKyQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENOtsiAadressiKyQuery clazz;
        
        public ENOtsiAadressiKyQuerySerializer(IENOtsiAadressiKyQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Katastritunnus!=null) {
                Writer.WriteStartElement("katastritunnus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Katastritunnus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PVcOper!=null) {
                Writer.WriteStartElement("p_vcOper");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PVcOper))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "katastritunnus")) {
                goto katastritunnus;
            }
            else {
                if ((Reader.LocalName == "p_vcOper")) {
                    goto p_vcOper;
                }
                else {
                    return;
                }
            }
        katastritunnus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiKy_query>katastritunnus");
            }
            clazz.Katastritunnus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("katastritunnus")).Value;
            goto START;
        p_vcOper:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiKy_query>p_vcOper");
            }
            clazz.PVcOper = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("p_vcOper")).Value;
            goto START;
        }
    }
}
